<?php 
header("content-type:text/html;charset=utf8");
$appId = isset($_GET['appId'])?$_GET['appId']:'';
$return = array();
if (empty($appId)) {
	$return['code'] = 10001;
	$return['data'] = 'Lack of necessary parameters';
}else{
	$res = updateLoginStatus($appId);
	if ($res) {
		$return['code'] = 10000;
		$return['data'] = 'Log in successfully';
	}else{
		$return['code'] = 10002;
		$return['data'] = 'Log out failed, please check the network status';
	}
 }

echo json_encode($return);

//用户发起退出登陆，将appId下面所有对应的数据状态都改变为0
function updateLoginStatus($appId){
	$pdo = new PDO('mysql:host=123.57.16.97;dbname=project','root','zqVnUy6cxsQXbpEZ');
	$pdo->exec("set names utf8");
	$sql = "UPDATE `relation` SET status = 0 WHERE appid = '".$appId."'";
	$res = $pdo->exec($sql);
	if ($res) {
		return 1;
	}else{
		return 0;
	}
}